package com.haha.FileCode;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class TestFileChannel {
    public static void main(String[] args) {
        try ( FileChannel from = new FileInputStream("E:\\gulimail\\nettystudy\\word.txt").getChannel();
              FileChannel to =new FileOutputStream("E:\\gulimail\\nettystudy\\to.txt").getChannel()){
           for (long left=from.size();left>0;){
               left-=from.transferTo(from.size()-left,from.size(),to);
           }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
